/****************************************Copyright (c)****************************************************

**--------------File Info---------------------------------------------------------------------------------
** File name:                sht40.h
** Last modified Date:       2024.11.14
** Last Version:             Ver:1.0
** Descriptions:             SHT40温湿度IC驱动
**
**--------------------------------------------------------------------------------------------------------
** Created by:               adm
** Created date:             2024.11.14
** Version:                  Ver:1.0
** Descriptions:             使用本驱动，需要调用i2c_application中间件
**--------------------------------------------------------------------------------------------------------*/
#ifndef SHT40_H
#define SHT40_H

#include "at32f415_wk_config.h"


/**************************I2C地址****************************/
#define SHT40_ADDRESS       0x88
#define SHT40_Write         (0x44<<1)                   //写入地址
#define SHT40_Read          ((0x44<<1)+1)               //读出地址

#define CRC8_POLYNOMIAL     0x31
/**************************SHT40命令****************************/
#define SHT40_CMD_MEASURE_HPM               0xFD        //高精度读取温湿度命令
#define SHT40_CMD_MEASURE_MPM               0xF6        //中等精度读取温湿度命令
#define SHT40_CMD_MEASURE_LPM               0xE0        //低精度读取温湿度命令
#define SHT40_CMD_READ_SERIAL               0x89        //读取唯一序列号命令
#define SHT40_CMD_SOFT_RESET                0x94        //软复位
#define SHT40_CMD_200W_1S                   0x39        //200mW加热1秒命令
#define SHT40_CMD_200W_01S                  0x32        //200mW加热0.1秒命令
#define SHT40_CMD_110W_1S                   0x2F        //110mW加热1秒命令
#define SHT40_CMD_110W_01S                  0x24        //110mW加热0.1秒命令
#define SHT40_CMD_20W_1S                    0x1E        //20mW加热1秒命令
#define SHT40_CMD_20W_01S                   0x15        //20mW加热0.1秒命令

/**************************API****************************/
void SHT40_Init(void);
void SHT40_Read_Temperature_Humidity(float *Temperature, float *Humidity);
uint32_t SHT40_Read_Serial_Number(void);
void SHT40_Heater_200mW_1s(void);


#endif /* SHT40_H */
